﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CPS1
{
    // NUDY: Patrz VaultSignal
    public class UniformNoise : Signal
    {
        private Random rand; // generator liczb losowych

        public UniformNoise(Double A, Double t1, Double d, Double f, String name) 
        {
            this.A = A;
            this.t1 = t1;
            this.d = d;
            this.f = f;
            this.name = name;
            this.periodical = false;
            this.discrete = false;

            int amount = (int) Math.Ceiling(d * f);
            this.calculatedValues = new Double[amount, 2];

            this.rand = new System.Random();
        }

        override public Double value(Double t) 
        {
            return -this.A + (this.rand.NextDouble() * (2 * this.A)); // wartość szumu dostosowana do amplitudy
        }

        public override Signal copy()
        {
            UniformNoise copied = new UniformNoise(this.A, this.t1, this.d, this.f, this.name);
            copied.calculateSignal();
            return copied;
        }
    }
}
